#ifndef HelperFunctions_h__
#define HelperFunctions_h__

class Task;
class Feature
{
public:
    QByteArray data;
public:
    double diffRate(const Feature &other)
    {
        return (double)diffCount(other) / data.size();
    }
    int diffCount(const Feature &other)
    {
        int n = 0;
        auto p1s = this->data.constData();
        auto p1e = p1s + this->data.size();
        auto p2s = other.data.constData();
        while (p1s != p1e)
            if (*p1s++ != *p2s++)
                n++;
        return n / 4;
    }
};

void mouseclick();

void keydown(DWORD vk, unsigned int delay = 100);
void keyup(DWORD vk, unsigned int delay = 100);
void pressKey(DWORD vk, unsigned int downDelay = 100, unsigned int upDelay = 100);
void pressCombine2(DWORD vkcontrol, DWORD vk, unsigned int downDelay = 100, unsigned int upDelay = 100);

QPixmap captureFullScreen();
void captureActiveWindow();
void pressControlV();
void pressAltS();

void playSound(const QString &path);

Feature qqFeature(HWND qqWindow);

void bringFirefoxWindowToTopGentlly(const QString &firefoxKeywrod);
void bringWindowToTopGentlly(HWND window);
void captureActiveWindowGentlly();
QPixmap captureWindow(HWND window);
void pressControlVGentlly();
void makeQQPasteAndSend(HWND qqWindow);
bool shotFirefoxAndSendToQQ(const QString& firefoxKeyword, const QString &QQKeyword, const QString &description, Task *task);

HWND findWindow(const QString windowClass, const QString &name);
HWND findQQWindow(const QString &name);
HWND findFirefoxWindow(const QString &name);
void bringWindowToTop(HWND window);

HWND getSupportQQWindow(const QString &keyword);

void sendChar(HWND window, int charactor);
void sendString(HWND window, const QString &str);

#endif // HelperFunctions_h__